<template>
  <div class="Ranking">
    <div class="Icon">
      <div v-if="active == 0">
        <div class="floats">
          <p v-show="dels" class="ift-edit" @click="del"></p>
          <p v-show="!dels" @click="del">完成</p>
        </div>
      </div>
      <div v-if="active != 0">
        <div class="floats ift-del" @click="delData"></div>
      </div>
    </div>
    <van-tabs v-model="active" animated title-active-color="#fc6976">
      <van-tab :title="'收藏'">
        <div class="empty" v-show="!image.length">
          <img src="../assets/mascot-fish.png" alt="" />
          <p>主人,暂时没有收藏漫画哦~</p>
        </div>
        <div class="have" v-show="image.length">
          <div class="free">
            <div class="images">
              <div v-if="dels">
                <div
                  class="degree-of-heat"
                  v-for="(item, index) in image"
                  :key="index"
                  @click="details(item.names)"
                >
                  <img :src="item.OuterLayer" alt="" />
                  <i class="choice" v-show="!dels">
                    <p v-show="!item.flass"></p>
                    <p v-show="item.flass" class="iconfont icon-dagou"></p>
                  </i>
                  <div class="Number-of-people">{{ item.names }}</div>
                </div>
              </div>
              <div v-if="!dels">
                <div
                  class="degree-of-heat"
                  v-for="(item, index) in image"
                  :key="index"
                  @click="flags(index)"
                >
                  <img :src="item.OuterLayer" alt="" />
                  <i class="choice" v-show="!dels">
                    <p v-show="!item.flass"></p>
                    <p v-show="item.flass" class="iconfont icon-dagou"></p>
                  </i>
                  <div class="Number-of-people">{{ item.names }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </van-tab>
      <van-tab :title="'历史'">
        <div class="empty" v-show="!history.length">
          <img src="../assets/mascot-fish.png" alt="" />
          <p>主人,暂时没有阅读历史~</p>
        </div>
        <div v-show="history.length">
          <div class="transverse" v-for="(item, index) in history" :key="index">
            <img :src="item.OuterLayer" alt="" />
            <div class="name">
              <h1>{{ item.names }}</h1>
              <h2>
                <span v-for="(k, i) in item.fl" :key="i">{{ k }}</span>
              </h2>
              <h3>更新至第{{ item.data.length - 1 }}话</h3>
            </div>
            <div class="continue">
              <div @click="details(item.id)">继续阅读</div>
              <div @click="deletes(index)">删除</div>
            </div>
          </div>
        </div>
      </van-tab>
    </van-tabs>
    <div class="delQB" v-show="!dels">
      <div class="del">
        <div @click="SelectAll">全选</div>
        <div @click="DeleteData">删除</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      active: 0,
      image: [],
      leg: "",
      history: [
        {
          id: 1,
          url: "https://image.yqmh.com/mh/107490.jpg-300x400.webp",
          name: "元尊",
          classification: "热血",
          people: 11111,
        },
        {
          id: 1,
          url: "https://image.yqmh.com/mh/107490.jpg-300x400.webp",
          name: "元尊",
          classification: "热血",
          people: 11111,
        },
        {
          id: 1,
          url: "https://image.yqmh.com/mh/107490.jpg-300x400.webp",
          name: "元尊",
          classification: "热血",
          people: 11111,
        },
        {
          id: 1,
          url: "https://image.yqmh.com/mh/107490.jpg-300x400.webp",
          name: "元尊",
          classification: "热血",
          people: 11111,
        },
        {
          id: 1,
          url: "https://image.yqmh.com/mh/107490.jpg-300x400.webp",
          name: "元尊",
          classification: "热血",
          people: 11111,
        },
        {
          id: 1,
          url: "https://image.yqmh.com/mh/107490.jpg-300x400.webp",
          name: "元尊",
          classification: "热血",
          people: 11111,
        },
      ],
      dels: true,
      hist: "",
    };
  },
  methods: {
    delData() {
      this.$store.commit("delData");
      this.history = this.$store.state.hist;
    },
    deletes(index) {
      this.$store.commit("histdel", index);
    },
    SelectAll() {
      this.$store.commit("SelectAll");
      this.image = this.$store.state.image;
    },
    del() {
      this.dels = !this.dels;
    },
    DeleteData() {
      this.$store.commit("DeleteData");
      this.del();
      this.image = this.$store.state.BookList;
    },
    flags(index) {
      this.$store.commit("flags", index);
    },
    details(id) {
      this.$router.push({ name: "details", query: { id: id } });
    },
  },
  created() {
    this.image = this.$store.state.BookList;
    console.log(this.image);
    this.history = this.$store.state.hist;
  },
};
</script>
<style lang="less">
.Ranking {
  width: 100%;
  height: 100vh;
  position: relative;
  .Icon {
    width: 90px;
    height: 45px;
    line-height: 45px;
    position: absolute;
    right: 0;
    z-index: 10;
    div {
      color: #fc6976;
      .floats {
        width: 50%;
        font-size: 22px;
        text-align: center;
        float: right;
        p {
          margin: 0;
          &:nth-child(2) {
            font-size: 14px;
          }
        }
      }
    }
  }
  .van-tabs {
    padding-bottom: 70px;
    .van-tabs__wrap {
      margin-left: 7%;
      width: 30%;
      .van-tabs__line {
        background-color: #fc6976;
        height: 2px;
      }
      .van-tab__text {
        font-size: 16px;
      }
    }
  }
  .empty {
    width: 100%;
    margin: 40% auto 0;
    text-align: center;
    img {
      width: 30%;
    }
    p {
      font-size: 12px;
      color: #999;
    }
  }
  .have {
    .free {
      width: 94%;
      margin: 10px auto;
      border-radius: 5px;
      .images {
        text-align: center;
        .degree-of-heat {
          float: left;
          height: 100%;
          margin: 0 1.6% 5px;
          width: 30%;
          position: relative;
          .choice {
            width: 15px;
            height: 15px;
            line-height: 15px;
            text-align: center;
            position: absolute;
            bottom: 20%;
            right: 0;
            padding: 1px;
            border-radius: 50%;
            p {
              width: 100%;
              height: 100%;
              border-radius: 50%;
              margin: 0;
              font-size: 12px;
              &:nth-child(1) {
                background-color: rgba(0, 0, 0, 0.6);
                box-sizing: border-box;
                border: 1px solid white;
              }
              &:nth-child(2) {
                background-color: #fc6976;
                color: white;
              }
            }
          }
          img {
            width: 100%;
            height: 70%;
          }
          .img {
            width: 100%;
            padding-bottom: 133%;
            box-shadow: 0 0 10px #f5c4d2;
          }
          .Number-of-people {
            padding: 5px 2px;
            color: #999;
            font-size: 14px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            span {
              margin-right: 2px;
            }
          }
        }
        .add {
          width: 28%;
          font-size: 14px;
          margin-bottom: 15%;
        }
      }
    }
  }
  .transverse {
    width: 96%;
    margin: 5% 2%;
    display: flex;
    img {
      width: 23%;
    }
    .name {
      width: 47%;
      padding: 1% 5%;
      position: relative;
      h1,
      h2,
      h3 {
        margin: 0;
        font-size: 14px;
        font-weight: 500;
      }
      h2 {
        font-size: 12px;
        color: #999;
      }
      h3 {
        position: absolute;
        bottom: 0;
        width: 100%;
        color: #ddd;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
    .continue {
      width: 20%;
      font-size: 14px;
      div {
        &:nth-child(1) {
          margin-top: 50%;
          background-color: #fc6976;
          color: white;
          text-align: center;
          border-radius: 10px;
          padding: 2% 3%;
        }
        &:nth-child(2) {
          margin-top: 5px;
          float: right;
        }
      }
    }
  }
  .delQB {
    width: 100%;
    height: 70px;
    padding-top: 20px;
    background-color: white;
    position: fixed;
    bottom: 0px;
    z-index: 10;
    .del {
      width: 100%;
      background-color: white;
      display: flex;
      text-align: center;
      justify-content: space-around;
      div {
        border: 1px solid #fc6976;
        padding: 1% 15%;
        border-radius: 20px;
        font-size: 14px;
        color: #fc6976;
      }
    }
  }
}
</style>